function draw()
{
    genDate();//先绘制一次，否则先调用setinterval会使浏览器有一秒钟的空白
    setInterval("genDate()",1000);//调用计时器

}
function genDate(){
    var myTime=document.getElementById("timeNow");
    var date = new Date();
    var yy = date.getFullYear();
    if(yy<1900) yy = yy+1900;
    var MM = date.getMonth()+1;
    if(MM<10) MM = '0' + MM;
    var dd = date.getDate();
    if(dd<10) dd = '0' + dd;
    var hh = date.getHours();
    if(hh<10) hh = '0' + hh;
    var mm = date.getMinutes();
    if(mm<10) mm = '0' + mm;
    var ss = date.getSeconds();
    if(ss<10) ss = '0' + ss;
    var ww = date.getDay();
    if (ww==0) ww="星期日";
    if (ww==1) ww="星期一";
    if (ww==2) ww="星期二";
    if (ww==3) ww="星期三";
    if (ww==4) ww="星期四";
    if (ww==5) ww="星期五";
    if (ww==6) ww="星期六";
    var str =  yy + "-" + MM + "-" + dd + " " + hh + ":" + mm + ":" + ss ;
    myTime.innerHTML=str;

    //         //拼接时间
    //         var dateStr = date.getFullYear()+"年"+(date.getMonth()+1)+"月"+date.getDate()+"日&nbsp;&nbsp"
    //             date.getHours()+"时"+date.getMinutes()+"分"+date.getSeconds()+"秒";
    //
    //         //2.获取span标签对象
    //         var spanTip = document.getElementById("timeNow");
    //
    //         // 3.设置span标签对象的innerHTML属性
    //         spanTip.innerHTML = dateStr;
}
